package com.yizhuoyan.his.ao;

import com.yizhuoyan.his.entity.FinExpenseCategoryEntity;
import lombok.Data;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.Max;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.Pattern;

@Data
public class FinExpenseCategoryAo {
    /**
     * 费用科目编码
     */
    @NotBlank(message = "费用科目编码不能为空")
    @Length(max = 16,message = "费用科目编码长度不能超过{max}")
    @Pattern(regexp = "[\\w-]+",message ="费用科目编码只能是字母数字和下划线,中横杠")
    private String code;
    /**
     * 费用科目名称
     */
    @NotBlank(message = "费用科目名称不能为空")
    @Length(max =32,message = "费用科目名称长度不能超过{max}")
    private String name;


    public static FinExpenseCategoryAo of(FinExpenseCategoryEntity e){
        FinExpenseCategoryAo finExpenseCategoryAo = new FinExpenseCategoryAo();
        finExpenseCategoryAo.setCode(e.getCode());
        finExpenseCategoryAo.setName(e.getName());
        return finExpenseCategoryAo;

    }
}
